package com.common.help.test18;
import java.util.Arrays;

public class Test2 {

	public static long[] test(){
		/************测试数据****************/
		//原有数组
		long[] arr = {10,33,101,136,400,450};
		//开始时间190，结束300
		long start = 140l;
		long end = 300l;
		
		long[] newarr = new long[arr.length + 2];
		/****************************************/
		//复制初始数组
		for(int i = 0; i < arr.length; i++){
			newarr[i] = arr[i];
		}
		newarr[arr.length] = start;
		newarr[arr.length + 1] = end;
		
		//排序
		Arrays.sort(newarr);
		
		//取出开始时间和结束时间所在的位置
		int indexstart = Arrays.binarySearch(newarr, start);
		int indexend = Arrays.binarySearch(newarr, end);
		System.out.println("start index " + indexstart);
		System.out.println("end index " + indexend);
		
		//生成新数组，只包含开始时间和结束时间以及他们之间的时间
		int newlength = indexend - indexstart + 1;
		long[] data = new long[newlength];
		for(int i = 0; i < newlength; i++){
			data[i] = newarr[indexstart + i];
		}
		for(int i = 0; i < data.length; i++){
			System.out.println(data[i]);
		}
		return data;
}
	
	public static void main(String[] args) {
		long[] aa= test();
		for(int i=0;i<aa.length-1;i++){
			if(i%2==0){
				System.out.println(aa[i]+","+aa[i+1]);
			}
		}
	}
}
